/*
 * @Author: your name
 * @Date: 2021-11-26 12:35:28
 * @LastEditTime: 2021-11-30 14:02:07
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \fd-industry-zhangjiang-company-terminal\vue.config.js
 */
const path = require('path');
const Webpack = require('webpack')
const AddAssetHtmlWebpackPlugin = require('add-asset-html-webpack-plugin')
const SpeedMeasureWebpackPlugin = require('speed-measure-webpack-plugin')
// eslint-disable-next-line no-unused-vars
const pxtorem = require('postcss-pxtorem')
const vendorManifest = require('./build/vendor/vendor-manifest')

function resolve(dir) {
  return path.join(__dirname, dir);
}

module.exports = {
  configureWebpack: {
    plugins: [
      new Webpack.ProvidePlugin({
        echarts: 'echarts'
      }),
      new Webpack.DllReferencePlugin({
        context: process.cwd(),
        manifest: vendorManifest
      }),

      // 将 dll 注入到 生成的 html 模板中
      new AddAssetHtmlWebpackPlugin({
        // dll文件位置
        filepath: path.resolve(__dirname, './build/vendor/*.js')
      })
    ]
  },
  chainWebpack: config => {
    config.resolve.alias
      .set('@', resolve('src'))
      .set('components', resolve('./src/components'))
      .set('views', resolve('./src/views'))
      .set('api', resolve('./src/api'))
      .set('assets', resolve('./src/assets'))
      .set('base', resolve('./src/base'))
      .set('utils', resolve('./src/utils'))
      .set('router', resolve('./src/router'))
      .set('store', resolve('./src/store'))
      .set('common', resolve('./src/common'))
      .set('mixins', resolve('./src/mixins'))
      .set('styles', resolve('./src/styles'))
      .set('static', resolve('./public/static'));
    config.plugin('speed').use(SpeedMeasureWebpackPlugin)
      .end()
  },
  productionSourceMap: false
};
